﻿using MediatR;
using SlaughterItem.Common.Domains.Detection;
using SlaughterItem.Common.Dtos;
using SlaughterItem.Common.Infrastructures.Interfaces;
using SlaughterItem.Enum;

namespace GetSlaughterItem.API.Application.Commands.Week02.ShowIPQCData
{
    /// <summary>
    ///获取检疫标准表数据
    /// </summary>
    public class ShowIPQCDataHandler : IRequestHandler<ShowIPQCDataCommand, Result>
    {
        public ShowIPQCDataHandler(IBaseRepositoryGet<PRQSData> pRQSDataRepositoryGet)
        {
            PRQSDataRepositoryGet = pRQSDataRepositoryGet;
        }

        public IBaseRepositoryGet<PRQSData> PRQSDataRepositoryGet { get; set; }
        public async Task<Result> Handle(ShowIPQCDataCommand request, CancellationToken cancellationToken)
        {
            var result=new Result() { Code=(int)CommonErrorCode.Search};
            var list = PRQSDataRepositoryGet.GetAll().ToList();
            if (list != null)
            {
                result.Data = list;
                result.Code = (int)CommonErrorCode.Success;
                return result;
            }
            else
            {
                return result;
            }
        }
    }
}
